import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LENOVO
 * Date: 2024-08-04
 * Time: 23:47
 */
/*
public class Homework {
    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4,5,6,7};
        int[] ret = new int[nums.length];
        int k = 3;
        int[] newNums = new int[nums.length + k];
        for (int i = k; i < nums.length + k; i++) {
            newNums[i] = nums[i - k];
        }
        for (int i = nums.length + k -1; i >= nums.length ; i--) {
            newNums[nums.length + k -1 - i] = newNums[i];
        }
        for (int i = 0; i < nums.length; i++) {
            ret[i] = newNums[i];
        }
        System.out.println(Arrays.toString(ret));
    }
}
*/
public class Homework {
    public static void main(String[] args) {
        int[] nums = new int[]{1,2,3,4,5,6,7};
        int[] ret = new int[nums.length];
        int k = 3;
        int k1 = k % nums.length;
        int[] newNums = Arrays.copyOf(nums,nums.length+k1);
        for (int i = 0; i < nums.length; i++) {
            newNums[i + k1 ] = nums[i];
        }
        for (int i = 0; i < k1; i++) {
            newNums[i] = newNums[newNums.length - k1 + i ];
        }
        System.out.println(Arrays.toString(newNums));
        for (int i = 0; i < nums.length; i++) {
            ret[i] = newNums[i];
        }
        System.out.println(Arrays.toString(ret));
    }
}